﻿using System;
using System.Collections.Generic;
using System.Text;

namespace PricePortalLib
{
    // Interface for items fetched from sub-suppliers and cached locally
    public interface IItem
    {
        // Sub-supplier code
        uint SubSupplier
        {
            get;
            set;
        }

        // Part number for item
        ulong PartNumber
        {
            get;
            set;
        }

        // Free text description of item
        string Description
        {
            get;
            set;
        }

        // Time when item was retrieved from sub-supplier
        DateTime Hit
        {
            get;
            set;
        }
    }

    // Interface for object that knows which sub-suppliers have been defined
    // and also knows how to search the sub-suppliers item data bases for items.
    public interface ISearchSubSupplier
    {
        // Return (possibly empty) list of items that match search criteria
        // partnumber = 0 (wild card) or specific part number
        // description = "" (wild card) or string with free text
        List<IItem> LookUpItem(ulong partnumber, string description);
    }

    // Interface for object used to locally cache data retrieved from
    // sub-suppliers
    public interface IItemCache
    {
        // Return (possibly empty) list of items that match search criteria
        // partnumber = 0 (wild card) or specific part number
        // description = "" (wild card) or string with free text
        List<IItem> LookUpItem(ulong partnumber, string description);
        // Add items (found through sub-suppliers) to local cache of known items
        void AddItems(List<IItem> items);
        // Remove items from local cache of known items (because they are too old)
        void RemoveItems(List<IItem> items);
    }

    // Interface for object used by web-frontend to get a list of items that
    // match search criteria entered by user.
    public interface IFindItem
    {
        // Return (possibly empty) list of items that match search criteria
        // partnumber = 0 (wild card) or specific part number
        // description = "" (wild card) or string with free text
        List<IItem> LookUpItem(ulong partnumber, string description);
        // Configure how long items in cache should be used
        void SetCacheExpireTime(uint hours);
    }
}
